#include <iostream>

using namespace std;

void jian(char& c, int k)
{
	//k mod
	k = k % 26;
	if ((int)c - k >= 97)
	{
		c = (char)(int)(c - k);
	}
	else
	{
		c = (char)(int)(c - k) + 26;
	}
}
int main()
{
	//A 65
	int a, b, c, n, tmp;
	//cout << (char)(65+25);
	string s1;
	cin >> s1 >> n;
	int** mat = new int* [n];
	int g, r;

	for (int i = 0; i < n; i++)
	{
		mat[i] = new int[3];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			scanf("%d", &mat[i][j]);
		}

	}

	for (int i = n - 1; i >= 0; i--)
	{
		for (int j = mat[i][0] - 1; j < mat[i][1]; j++)
		{
			jian(s1[j], mat[i][2]);
		}
		//cout << s1 << endl;
	}
	cout << s1;
}
